package br.com.infocruz.seam.crm.ejb.session;

import br.com.infocruz.seam.crm.ejb.model.*;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

@Name("auditTrailHome")
public class AuditTrailHome extends EntityHome<AuditTrail> {

	@In(create = true)
	UserAccountHome userAccountHome;

	public void setAuditTrailId(Long id) {
		setId(id);
	}

	public Long getAuditTrailId() {
		return (Long) getId();
	}

	@Override
	protected AuditTrail createInstance() {
		AuditTrail auditTrail = new AuditTrail();
		return auditTrail;
	}

	public void load() {
		if (isIdDefined()) {
			wire();
		}
	}

	public void wire() {
		getInstance();
		UserAccount userAccount = userAccountHome.getDefinedInstance();
		if (userAccount != null) {
			getInstance().setUserAccount(userAccount);
		}
	}

	public boolean isWired() {
		return true;
	}

	public AuditTrail getDefinedInstance() {
		return isIdDefined() ? getInstance() : null;
	}

}
